package com.ruoyi.web.controller.cs;

import java.util.List;

import com.ruoyi.common.core.controller.BasicsController;
import com.ruoyi.common.core.domain.Response;
import com.ruoyi.common.core.page.ResponsePageInfo;
import com.ruoyi.common.utils.poi.Excel2Util;
import com.ruoyi.cs.domain.TBalanceChange;
import com.ruoyi.cs.domain.TBattleBox;
import com.ruoyi.cs.service.ITBattleBoxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 对战所参与的盲盒Controller
 * 
 * @author ruoyi
 * @date 2021-08-05
 */
@Api(tags = {"对战所参与的盲盒"})
@RestController
@RequestMapping("/cs/battlebox")
public class TBattleBoxController extends BasicsController
{
    @Autowired
    private ITBattleBoxService tBattleBoxService;

    /**
     * 查询对战所参与的盲盒列表
     */
    @ApiOperation("查询对战所参与的盲盒列表")
    @PreAuthorize("@ss.hasPermi('cs:battlebox:list')")
    @GetMapping("/list")
    public ResponsePageInfo<TBattleBox> list(TBattleBox tBattleBox)
    {
        startPage();
        List<TBattleBox> list = tBattleBoxService.selectTBattleBoxList(tBattleBox);
        return toResponsePageInfo(list);
    }

    /**
     * 导出对战所参与的盲盒列表
     */
    @ApiOperation("导出对战所参与的盲盒列表")
    @PreAuthorize("@ss.hasPermi('cs:battlebox:export')")
    @Log(title = "对战所参与的盲盒", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public Response<String> export(TBattleBox tBattleBox)
    {
        List<TBattleBox> list = tBattleBoxService.selectTBattleBoxList(tBattleBox);
        Excel2Util<TBattleBox> util = new Excel2Util<TBattleBox>(TBattleBox.class);
        return util.exportExcel(list, "box");
    }

    /**
     * 获取对战所参与的盲盒详细信息
     */
    @ApiOperation("获取对战所参与的盲盒详细信息")
    @PreAuthorize("@ss.hasPermi('cs:battlebox:query')")
    @GetMapping(value = "/{battleboxId}")
    public Response<TBattleBox> getInfo(
            @ApiParam(name = "battleboxId", value = "对战所参与的盲盒ID", required = true)
            @PathVariable("battleboxId") String battleboxId)
    {
        return Response.success(tBattleBoxService.selectTBattleBoxById(battleboxId));
    }

    /**
     * 修改对战所参与的盲盒
     */
    @ApiOperation("修改对战所参与的盲盒")
    @PreAuthorize("@ss.hasPermi('cs:battlebox:add')")
    @Log(title = "对战所参与的盲盒", businessType = BusinessType.INSERT)
    @PostMapping
    public Response<Integer> add(@RequestBody TBattleBox tBattleBox)
    {
        return toResponse(tBattleBoxService.insertTBattleBox(tBattleBox));
    }

    /**
     * 修改对战所参与的盲盒
     */
    @ApiOperation("修改对战所参与的盲盒")
    @PreAuthorize("@ss.hasPermi('cs:battlebox:edit')")
    @Log(title = "对战所参与的盲盒", businessType = BusinessType.UPDATE)
    @PutMapping
    public Response<Integer> edit(@RequestBody TBattleBox tBattleBox)
    {
        return toResponse(tBattleBoxService.updateTBattleBox(tBattleBox));
    }

    /**
     * 删除对战所参与的盲盒
     */
    @ApiOperation("删除对战所参与的盲盒")
    @PreAuthorize("@ss.hasPermi('cs:battlebox:remove')")
    @Log(title = "对战所参与的盲盒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{battleboxIds}")
    public Response<Integer> remove(@PathVariable String[] battleboxIds)
    {
        return toResponse(tBattleBoxService.deleteTBattleBoxByIds(battleboxIds));
    }
}
